import axios from "axios";

async function addCustomer(creation) {
  let response = await axios.post("/basic/customer", creation);
  return response;
}

async function updateCustomer(customerId, update) {
  if (!customerId) {
    // return toastr.error("客户ID不正确")
  }
  let response = await axios.put("/basic/customer/" + customerId, update);
  return response;
}

async function searchCustomer(filter) {
  let response = await axios.post("/basic/customer/search", filter || {});
  return response;
}

async function getCustomerById(customerId) {
  if (!customerId) {
    // return toastr.error("客户ID不正确")
  }
  let response = await axios.get("/basic/customer/" + customerId);
  return response;
}

async function customerAgree(agree) {
  let response = await axios.put("/basic/customer/agree", agree);
  return response;
}

async function customerReject(reject) {
  let response = await axios.put("/basic/customer/reject", reject);
  return response;
}

async function openAutoBalance(open) {
  let response = await axios.put("/basic/customer/openAutoBalance", open);
  return response;
}

async function closeAutoBalance(close) {
  let response = await axios.put("/basic/customer/openAutoBalance", close);
  return response;
}
async function CustomerSearch(param) {
  let response = await axios.post("/basic/customer/search", param);
  return response;
}
async function ConsigneeSearch(param) {
  let response = await axios.post("/basic/consignee/search", param);
  return response;
}

async function exportCommon(param) {
  let response = await axios.post("/ems/export/common", param);
  return response;
}

export {
  addCustomer,
  updateCustomer,
  searchCustomer,
  getCustomerById,
  customerAgree,
  customerReject,
  closeAutoBalance,
  openAutoBalance,
  CustomerSearch,
  ConsigneeSearch,
  exportCommon
};
